using UnityEngine;
using System.Collections;

public class FiveHeadedDragon : Hero
{
	public WinOrLose winOrLose;
	float attackRadius = 25;
	float healPower = 10;
	public override void Attack1 ()
	{
		GameObject[] allUnitObjects = GameObject.FindGameObjectsWithTag("Unit");
		OfflineUnit[] attackedUnits = new OfflineUnit[allUnitObjects.Length];
		int count = 0;
		for(int i=0;i<allUnitObjects.Length;++i)
			if(Vector3.Distance(allUnitObjects[i].transform.position, transform.position) <= attackRadius)
				attackedUnits[count] = allUnitObjects[i].GetComponent<OfflineUnit>();
		for(int i=0;i<attackedUnits.Length;++i)
			if(attackedUnits[i] != null)
				attackedUnits[i].TakeDamage(AttackPower);
	}
	public override void Attack2 ()
	{
		GameObject[] allUnitObjects = GameObject.FindGameObjectsWithTag("Unit");
		OfflineUnit[] attackedUnits = new OfflineUnit[allUnitObjects.Length];
		int count = 0;
		for(int i=0;i<allUnitObjects.Length;++i)
			if(Vector3.Distance(allUnitObjects[i].transform.position, transform.position) < attackRadius)
				attackedUnits[count] = allUnitObjects[i].GetComponent<OfflineUnit>();
		for(int i=0;i<attackedUnits.Length;++i)
			if(attackedUnits[i] != null)
				attackedUnits[i].Heal(healPower);
	}
	public override void DeleteMe ()
	{
		winOrLose.win = true;
		Application.LoadLevel("Offline_End_Game_Menu");
	}
}
